﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using CodeGame.ServerObjects;

namespace CodeGame.Networking.Serverside.ClientServerPackets
{
    class WorldPulsePacket : ServerPacket
    {
        public override ClientServerNet GetID()
        {
            return ClientServerNet.WorldPulseRequest;
        }

        public override void Handle(Lidgren.Network.NetIncomingMessage message, Lidgren.Network.NetConnection sender)
        {
            string id = message.ReadString();
            ServerObjects.Entity ent = ServerSingletons.World.GetEntity(true,id);
            Player ply = ServerSingletons.Players.GetPlayer(sender);
            if (ply.WithdrawResouces(Balence.PulseEntity))
            {
                ServerProtocolChat.SendPrivateChat("", ServerSingletons.World.Pulse(500, ent.X, ent.Y), sender);
            }
        }

    }
}
